<template>
  <div>
    <div class="herdertop">
      <img src="../../assets/top.png" alt="" class="topImg" />
      <el-breadcrumb separator="/">
        <el-breadcrumb-item>服务管理</el-breadcrumb-item>
        <el-breadcrumb-item>报事报修管理</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="center" style="padding-top: 0px;">
      <div class="hander">报事报修管理</div>
      <div class="orderList">
        <div class="entirety">
          <div>
            <div class="search">
              <!--  账号状态搜索信息 -->
              <div class="demo-input-suffix">
                城市

                <el-select
                  v-model="cityCode"
                  @change="busstwo"
                  style="width: 65%"
                  placeholder="请选择"
                >
                  <el-option
                    v-for="item in communityList"
                    :key="item.subRgCode"
                    :label="item.subRgName"
                    :value="item.subRgCode"
                  >
                  </el-option>
                </el-select>
              </div>
              <div class="demo-input-suffix">
                项目名称

                <el-select
                  :disabled="cityCode === ''"
                  v-model="communityCode"
                  style="width: 65%"
                  placeholder="请选择"
                >
                  <el-option
                    v-for="item in authHouseList"
                    :key="item.communityCode"
                    :label="item.communityName"
                    :value="item.communityCode"
                  >
                  </el-option>
                </el-select>
              </div>
              <div class="demo-input-suffix">
                业主名称

                <el-input
                  style="width: 65%"
                  v-model="userName"
                  placeholder="输入名称"
                ></el-input>
              </div>

              <div class="demo-input-suffix">
                报事类型

                <el-select
                  style="width: 65%"
                  v-model="serviceId"
                  placeholder="请选择"
                >
                  <el-option
                    v-for="item in servicebylist"
                    :key="item.id"
                    :label="item.serviceName"
                    :value="item.id"
                  >
                  </el-option>
                </el-select>
              </div>
            </div>
            <div class="search">
              <!--  账号状态搜索信息 -->
              <div class="demo-input-suffix">
                报事状态
                <el-select
                  style="width: 65%"
                  v-model="trackCode"
                  placeholder="请选择"
                >
                  <el-option
                    v-for="item in trackNodes"
                    :key="item.dictCode"
                    :label="item.dictName"
                    :value="item.dictCode"
                  >
                  </el-option>
                </el-select>
              </div>
              <div class="demo-input-suffix">
                报事终端
                <el-select
                  style="width: 65%"
                  v-model="platformType"
                  placeholder="请选择"
                >
                  <el-option label="IOS" value="IOS"></el-option>
                  <el-option label="小程序" value="小程序"></el-option>
                  <el-option label="Android" value="Android"></el-option>
                </el-select>
              </div>
              <!--  账号状态搜索信息 -->
              <div class="demo-input-suffix">
                <el-button
                  style="background-color:#fd804c;color: #fff;"
                  @click.native.prevent="isSelect"
                  >查询</el-button
                >
                <el-button type="warning" @click.native.prevent="isEmpty"
                  >清空</el-button
                >
              </div>
            </div>
          </div>
        </div>
        <!-- nav展示 -->
        <div class="nav">
          <div class="money" style="width: 24%;cursor:pointer">
            <div class="moneyLeft">
              <div class="one">
                {{ allTotal }}
              </div>
              <el-tooltip
                class="item hand"
                effect="dark"
                content="总报事数"
                placement="top-start"
              >
                <div class="newTitle">
                  <div class="two">总报事数</div>
                </div>
              </el-tooltip>
            </div>
          </div>
          <!-- 完结报事数-->
          <div class="money" style="width: 24%">
            <div class="moneyLeft">
              <div class="one">
                {{ completedTotal }}
              </div>
              <el-tooltip
                class="item"
                effect="dark"
                content="完结报事数"
                placement="top-start"
              >
                <div class="newTitle">
                  <div class="two">完结报事数</div>
                </div>
              </el-tooltip>
            </div>
          </div>
          <!-- 上周报事数 -->
          <div class="money" style="width: 24%">
            <div class="moneyLeft">
              <div class="one">
                {{ lastWeekTotal }}
              </div>

              <el-tooltip
                class="item"
                effect="dark"
                content="上周报事数"
                placement="top-start"
              >
                <div class="newTitle">
                  <div class="two">上周报事数</div>
                </div>
              </el-tooltip>
            </div>
          </div>
          <!-- 今日报事数-->
          <div class="money" style="width: 24%">
            <div class="moneyLeft">
              <div class="one">
                {{ todayTotal }}
              </div>

              <el-tooltip
                class="item"
                effect="dark"
                content="今日报事数"
                placement="top-start"
              >
                <div class="newTitle">
                  <div class="two">今日报事数</div>
                </div>
              </el-tooltip>
            </div>
          </div>
        </div>
        <!--  报事报修管理列表栏位-->
        <div
          class="entirety"
          v-loading="isLoading"
          element-loading-text="数据加载中"
          element-loading-spinner="el-icon-loading"
          element-loading-custom-class="loading_color"
        >
          <div class="footer">
            <el-table :data="tableData" style="width: 100%">
              <el-table-column prop="orderNo" label="报事单号">
                <template slot-scope="scope">
                  <div>
                    {{ scope.row.orderNo }}
                  </div>
                </template>
              </el-table-column>

              <el-table-column prop="cityName" label="城市">
                <template slot-scope="scope">
                  <div>
                    {{ scope.row.cityName }}
                  </div>
                </template>
              </el-table-column>
              <el-table-column prop="communityName" label="项目名称">
                <template slot-scope="scope">
                  <div>
                    {{ scope.row.communityName }}
                  </div>
                </template>
              </el-table-column>
              <el-table-column prop="houseName" label="房间号">
                <template slot-scope="scope">
                  <div>
                    {{ scope.row.houseName }}
                  </div>
                </template>
              </el-table-column>
              <el-table-column prop="userName" label="业主姓名">
                <template slot-scope="scope">
                  <div>
                    {{ scope.row.userName }}
                  </div>
                </template>
              </el-table-column>
              <el-table-column prop="serviceName" label="报事类型">
                <template slot-scope="scope">
                  <div>
                    {{ scope.row.serviceName }}
                  </div>
                </template>
              </el-table-column>
              <el-table-column prop="platformType" label="报事终端">
                <template slot-scope="scope">
                  <div>
                    {{ scope.row.platformType }}
                  </div>
                </template>
              </el-table-column>
              <el-table-column prop="createTime" label="报事时间">
                <template slot-scope="scope">
                  <div>
                    {{ scope.row.createTime }}
                  </div>
                </template>
              </el-table-column>
              <el-table-column prop="trackName" label="状态">
                <template slot-scope="scope">
                  <div>
                    {{ scope.row.trackName }}
                  </div>
                </template>
              </el-table-column>
              <el-table-column prop="payTotalFee" label="费用">
                <template slot-scope="scope">
                  <div>
                    {{ scope.row.payTotalFee }}
                  </div>
                </template>
              </el-table-column>
              <el-table-column fixed="right" label="操作">
                <template slot-scope="scope">
                  <el-button
                    @click.native.prevent="isDetail(scope.row.orderNo)"
                    style="color: #fc9e76;"
                    type="text"
                    size="small"
                  >
                    详情
                  </el-button>
                </template>
              </el-table-column>
            </el-table>
            <div class="block">
              <div class="left"></div>
              <div class="right">
                <el-pagination
                  layout="total, sizes, prev, pager, next, jumper"
                  class="page"
                  @size-change="sizeChangeHandle"
                  @current-change="currentChangeHandle"
                  :current-page="pageIndex"
                  :page-size="pageSize"
                  :total="total"
                >
                </el-pagination>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      cityCode: "",
      serviceCode: "",
      createTime: "",
      platformType: "",
      serviceId: "",
      trackCode: "",
      memberNo: "",
      communityCode: "",
      isLoading: false,

      userName: "",
      pageIndex: 1,
      pageSize: 20,
      total: 0,
      tableData: [],
      id: "",
      completedTotal: "0",
      lastWeekTotal: "0",
      todayTotal: "0",
      allTotal: "0",
      userSearch: 0,
      servicebylist: [],
      authHouseList: [],
      trackNodes: [],
      communityList: []
    };
  },
  activated() {
    this.memberNo = this.$route.params.memberNo || "";

    this.DetailByPage();
    this.fetchRegionCommunityList();
    this.getWorkOrderServiceByPage();
    this.getWorkOrderTrackNode();
    this.isEmpty();
    this.getCondition();
  },
  methods: {
    // 更换
    busstwo(val) {
      console.log("val,,,,,,,,,", val);
      if (val == "") {
        this.communityCode = "";
      }
      // 监听城市的选择 筛选商圈的枚举
      if (val) {
        let businessArray = [];
        businessArray = this.communityList.find(item => item.subRgCode === val)
          .cityCommunityDict;
        if (businessArray) {
          this.authHouseList = businessArray;
          this.communityCode = "";
        }
      }
    },
    isSelect() {
      (this.pageIndex = 1), (this.pageSize = 20), this.DetailByPage();
    },
    getCondition() {
      this.$http({
        url: "/orderadmin/mgr/workOrder/getCondition",
        method: "GET"
      }).then(res => {
        (this.completedTotal = res.completedTotal),
          (this.lastWeekTotal = res.lastWeekTotal),
          (this.todayTotal = res.todayTotal),
          (this.allTotal = res.total);
      });
    },
    isEmpty() {
      (this.userName = ""),
        (this.cityCode = ""),
        (this.serviceCode = ""),
        (this.createTime = ""),
        (this.platformType = ""),
        (this.serviceId = ""),
        (this.trackCode = ""),
        (this.memberNo = ""),
        (this.userName = ""),
        (this.communityCode = ""),
        (this.pageIndex = 1),
        (this.pageSize = 20),
        this.DetailByPage();
    },
    //详情
    isDetail(orderNo) {
      this.$router.push({
        path: "/repairInfo",
        query: {
          orderNo
        }
      });
    },

    getWorkOrderServiceByPage() {
      this.$http({
        url: "/orderadmin/mgr/workOrder/getWorkOrderServiceByPage",
        method: "POST",
        data: {
          size: 0,
          page: 1
        }
      }).then(res => {
        this.servicebylist = res.data.list;
      });
    },
    getWorkOrderTrackNode() {
      this.$http({
        url: "/orderapp/mgr/workOrder/getWorkOrderTrackNode",
        method: "GET"
      }).then(res => {
        this.trackNodes = res.data;
      });
    },

    fetchRegionCommunityList() {
      this.$http({
        url: "/memberadmin/mgr/userCenter/fetchRegionCommunityList",
        method: "GET"
      }).then(res => {
        this.communityList = res;
      });
    },

    //分页获取优惠券模板列表接口调用
    DetailByPage() {
      this.isLoading = true;

      this.$http({
        url: `/orderadmin/mgr/workOrder/getWorkOrderByPage`,
        method: "POST",
        data: {
          cityCode: this.cityCode,
          communityCode: this.communityCode,
          createTime: this.createTime,
          memberNo: this.memberNo,
          platformType: this.platformType,
          serviceId: this.serviceId,
          trackCode: this.trackCode,
          userName: this.userName,
          size: this.pageSize,
          page: this.pageIndex
        }
      })
        .then(res => {
          this.tableData = res.data.list;
          this.isLoading = false;
          this.total = parseInt(res.data.total);
        })
        .catch(_ => {
          this.isLoading = false;
        });
    },
    // 每页数
    sizeChangeHandle(val) {
      this.pageSize = val;
      this.pageIndex = 1;

      this.DetailByPage();
    },
    // 当前页
    currentChangeHandle(val) {
      this.pageIndex = val;

      this.DetailByPage();
    }
  }
};
</script>
<style scoped lang="scss">
.block {
  width: 100%;
  height: 70px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-sizing: border-box;
  padding: 0 10px 0 10px;
}
.left {
  font-size: 15px;
}
.hander {
  width: 100%;
  height: 50px;
  line-height: 50px;
  font-size: 20px;
  font-weight: 900;
}
.balance-searchMoney {
  display: flex;
  align-items: center;
}
.input {
  flex: 1;
  margin-left: 5px;
}
.nav {
  width: 102%;
  margin-top: 12px;
  margin-left: 10px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
}
.money {
  // height: 100px;
  background-color: #fff;
  padding: 10px;
  box-sizing: border-box;
  display: flex;
  border-radius: 6px;
  // margin-bottom: 24px !important;
}

.money div {
  color: #333;
  box-sizing: border-box;
}
.one {
  font-size: 20px;
  font-weight: 500;
  color: #000;
}
.money .two {
  font-size: 12px;
  color: #666;
  font-weight: 500;
}
.moneyRight {
  display: flex;
  justify-content: center;
  align-items: center;
  flex: 1;
}
.moneyImg {
  width: 72px;
  height: 72px;
}

.f16 {
  font-size: 16px;
}
.moneyLeft {
  flex: 1;
  background: #f2f2f2;
  text-align: center;
  padding-top: 10px;
  padding-bottom: 10px;
}

.news {
  margin-left: 4%;
}
.orderList {
  background-color: #ebeef1;
  padding-right: 40px;
  padding-top: 1px;
  padding-bottom: 1px;
  display: block;
  font-size: 16px;
  border-radius: 20px;
  list-style-type: none;
}
.entirety {
  width: 100%;
  margin: 10px;
  height: 100%;
  padding: 10px;
  background-color: #fff;
  border-radius: 10px;
  display: flex;
  padding-left: 10px;
  .basic {
    font-size: 18px;
    font-weight: 900;
    margin-top: 2%;
    margin-bottom: 1%;
    margin-left: 1%;
  }
}
.footer {
  width: 100%;
  display: flex;
  overflow: hidden;
  flex-direction: column;
}
.search {
  margin-bottom: 15px;
}
.page {
  margin-top: 15px;
}
.overall {
  width: 100%;
  height: auto;
  display: flex;

  justify-content: space-between;
  margin-top: 3%;
  .left {
    width: 20%;
    height: auto;
  }
  .right {
    width: 80%;
    height: auto;
  }
}
.demo-input-suffix {
  margin-left: 1%;
}
.select {
  width: 65%;
  height: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  .dialog-footer,
  .choice {
    margin-left: 2%;
  }
}
.herdertop {
  height: 8vh;
  display: flex;
  align-items: center;
  padding: 0 20px;
  box-sizing: border-box;
}
.topImg {
  margin-right: 20px;
}
/deep/ .el-loading-spinner i {
  color: #fc9e76;
}
/deep/ .el-loading-spinner .el-loading-text {
  color: #fc9e76;
  margin: 3px 0;
  font-size: 14px;
}
/deep/ .itemClass .el-form-item__content {
  width: 350px;
}
.userSearch {
  display: flex;
  /deep/ .el-input__inner {
    box-sizing: border-box;
    height: 40px;
    border-radius: 0;
    width: 132px;
    border: 1px solid #dcdfe6;
  }
  /deep/ .el-icon-arrow-up:before {
    position: relative;
    top: -4px;
  }
  /deep/ .el-button {
    height: 40px;
    border-radius: 0;
    background-color: #fff;
    border: 1px solid #dcdfe6;
    border-left: none;
    border-top-right-radius: 4px;
    border-bottom-right-radius: 4px;
    position: relative;
    .el-icon-search {
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
    }
  }
  /deep/ .el-input--suffix .el-input__inner {
    border-right: none;
  }
  /deep/ .el-input--suffix .el-input__inner {
    border-top-left-radius: 4px;
    border-bottom-left-radius: 4px;
  }
}
.selects {
  width: 55%;
  height: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  .dialog-footer,
  .choice {
    margin-left: 2%;
  }
}

/deep/ .but {
  background: #fd7097;
  color: #fff;
  margin-bottom: 1%;
}
</style>
